<!DOCTYPE html>
<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="../js/easyui/themes/default/easyui.css" />
<link rel="stylesheet" href="../js/easyui/themes/icon.css" />

<!--引入jquery的ztree-->
<script type="text/javascript" src="../js/ztree/jquery.ztree.all-3.5.js"></script>
<link rel="stylesheet" href="../js/ztree/zTreeStyle.css" />
<html>

	<head>
		<meta charset="UTF-8">
		<title>accordion折叠面板</title>
	</head>

	<script>
		$(function() {
			var setting = {
				data: {
					simpleData: {
						enable: true,
						idKey: "id", // 不写，默认是id
						pIdKey: "pId" // 不写，默认是pId
					}
				},
				callback: {
					onClick: function(event, treeId, treeNode, clickFlag) {
						// alert(treeId+"    "+treeNode+"   "+treeNode.name+"    "+treeNode.page);
						var content = '<div style="width:100%;height:100%;overflow:hidden;">' +
							'<iframe src="' +
							treeNode.page +
							'" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';
						if(treeNode.page != null && treeNode.page != undefined) {
							// 如果选项卡存在，此时选中选项卡
							if($('#mytabs').tabs('exists', treeNode.name)) {
								$('#mytabs').tabs('select', treeNode.name);
							}
							// 如果选项卡不存在，此时创建一个新的选项卡
							else {
								// 添加选项卡
								$('#mytabs').tabs('add', {

									title: treeNode.name,

									content: content,

									closable: true,

									tools: [{

										iconCls: 'icon-mini-refresh',

										handler: function() {

											alert('refresh');

										}

									}]

								});
							}
						}

					}
				}
			};
			// 2、提供ztree树形菜单数据 
			var zNodes = [{
				id: 1,
				pId: 0,
				name: "父节点一"
			}, {
				id: 2,
				pId: 0,
				name: "父节点二"
			}, {
				id: 11,
				pId: 1,
				name: "传智播客",
				page: "http://www.itcast.cn"
			}, {
				id: 12,
				pId: 1,
				name: "百度",
				page: "http://www.baidu.com"
			}, {
				id: 13,
				pId: 2,
				name: "子节点三"
			}, {
				id: 14,
				pId: 2,
				name: "子节点四"
			}];
			$.fn.zTree.init($("#tree"), setting, zNodes);
			
			// 在选项卡的上面，右键事件
			$("#mytabs").tabs({
				onContextMenu:function(e,title,index){
					e.preventDefault();// 阻止默认的右键事件
					$('#mm').menu('show', {
						left: e.pageX,
						top: e.pageY
					});
				}
			})
		})
	</script>

	<body class="easyui-layout">

		<div data-options="region:'north',title:'首页Logo',split:true" style="height:100px;"></div>

		<div data-options="region:'south',title:'版权',split:true" style="height:100px;"></div>

		<div data-options="region:'east',iconCls:'icon-reload',title:'查询条件'" style="width:100px;"></div>

		<div data-options="region:'west',title:'菜单',split:true" style="width:260px;">
			<div id="myaccordion" class="easyui-accordion" data-options="fit:true" style="width:300px;height:200px;">

				<div title="基本功能" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">

					<ul id="tree" class="ztree" style="width:260px; overflow:auto;"></ul>

				</div>

				<div data-options="iconCls:'icon-reload',selected:true,title:'系统管理'" style="padding:10px;">

					系统管理

				</div>

			</div>

		</div>

		<div data-options="region:'center'">
			<div id="mytabs" class="easyui-tabs" fit='true' style="width:500px;height:250px;">

				<div title="消息中心" data-options="closable:true" style="overflow:auto;padding:20px;display:none;">tab2 </div>

				<div title="论坛" data-options="iconCls:'icon-reload',closable:true,selected:true" style="padding:20px;display:none;">tab3 </div>

			</div>

		</div>

		<div id="mm" class="easyui-menu" style="width:120px;">

			<div>关闭当前窗口</div>

			<div data-options="iconCls:'icon-cancel'">关闭其他窗口</div>

			<div class="menu-sep"></div>

			<div>关闭所有窗口</div>

		</div>

	</body>

</html>